﻿@model List<DataAccess.Models.Role> 
<div class="row">
    <div class="col-lg-12">
        <div class="row">
            <div class="col-lg-12">
                <ol class="breadcrumb">
                    <li><a href="/">首页</a></li>
                    <li class="active"><span>系统管理</span></li>
                </ol>
                <div class="clearfix">
                    <h1 class="pull-left">用户群组管理</h1>
                    <div class="pull-right top-page-ui">
                        <a href="#" class="btn btn-primary pull-right md-trigger mrg-b-lg" data-modal="modal-13">
                            <i class="fa fa-plus-circle fa-lg"></i> 添加群组
                        </a>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="main-box no-header clearfix">
                    <header class="main-box-header clearfix">
                        <h2>群组管理</h2>
                    </header>
                    <div class="main-box-body clearfix">
                        <div class="table-responsive">
                            <table class="table table-bordered">
                                <thead>
                                    <tr>
                                        <th><span>群组</span></th>
                                        <th><span>状态</span></th>
                                        <th><span>操作</span></th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach (var item in Model)
                                    {
                                       <tr>
                                           <td>@item.name</td>
                                            <td>@Html.Raw(item.state == 1 ? "<span class='label label-success' name='state_" + item.id + "'>启用</span>" : "<span class='label label-danger' name='state_" + item.id + "'>禁用</span>")</td>
                                           <td>
                                               <a class="table-link" href="javascript:Edit(@item.id,'@item.name',@item.state)">[编辑]</a>
                                               &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:Set(@item.id,'@item.name')">[设置权限]</a>
                                           </td> 
                                            </tr> 
                                    }
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<input type="hidden" value="1" id="handle_status" />
@section Scripts{
   
   
   <script src="~/Scripts/plugins/layer/layer.min.js"></script>
<script type="text/javascript" src="~/Scripts/sys/lib/common_raw.js"></script>
    <script src="~/js/modalEffects.js"></script>
    <script src="~/js/classie.js"></script>
    <script type="text/javascript">
        var parengPanel;
        function Edit(id, rolename, state) {
            $("#name").val(rolename);
            $("#RoleState").prop("checked", state == 0 ? false : true);
            $("#id").val(id);
            $("#modal-13").addClass("md-show");

        }
        function Set(id, username) {
            window.location.href = '/setRole.html?id=' + id;

        }
       
        $(document).ready(function () {
          
            $("#submit").bind("click", function () {
                var name = $.trim($("input[name=name]").val());
                if (name.length == 0) {
                    layer.tips('名称不能为空！', 'input[name=name]', { tips: [2, '#78BA32'] });
                    return false;
                }
                var state = $("#RoleState").is(':checked') ? "1" : "0";
                var id = $("#id").val();
                common.invokeApi(
                    "post",
                    "/editRole.html",
                    { id: id, state: state, name: name },
                    function () { },
                    function (data) {
                        common.msg(data.Message, 1, function () {
                            location.reload();
                            
                           
                        });
                    },
                    function (data) {
                        common.msg(data.Message, 2, function () { });
                    },
                    function () { }
                    );
            });

        });
    </script>
}


<div class="md-modal md-effect-13" id="modal-13">
    <div class="md-content">
        <div class="modal-header">
            <button class="md-close close">&times;</button>
            <h4 class="modal-title">添加群组</h4>
        </div>
        <div class="modal-body">
            <div class="main-box-body clearfix">
                <form class="form-horizontal">
                    <input type="hidden" id="id" name="id" value="0" />
                    <div class="form-group">
                        <label for="name" class="col-lg-2 control-label">用户名:</label>
                        <div class="col-lg-5">
                            <input type="text" id="name" name="name" max="10" value="" class="form-control" placeholder="输入群组名称">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-10">
                            <div class=" checkbox checkbox-nice">
                                <input type="checkbox" name="RoleState" id="RoleState" checked="checked" />
                                <label for="RoleState">
                                    是否启用
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">

                        <button type="button" id="submit" class="btn btn-primary">保 &nbsp;&nbsp;&nbsp;存</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<div class="md-overlay"></div>